package com.woniuxy.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniuxy.controller.dto.MyonerepairDto;
import com.woniuxy.controller.form.ShowrepairForm;
import com.woniuxy.dao.info.myrepairInfo;
import com.woniuxy.dao.model.RepairInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 维修表 Mapper 接口
 * </p>
 *
 * @author Keep it simple
 * @since 2022-06-28
 */
public interface RepairInfoDao extends BaseMapper<RepairInfo> {



    @Select("SELECT repairNum,area_name,rp.project_name,ri.repairContent, ri.repairDate,a.account_name,(UNIX_TIMESTAMP(orderRepairDate) - UNIX_TIMESTAMP(repairDate))/60 resoptime,ri.repairState from repair_info ri \n" +
            "JOIN repair_project rp \n" +
            "ON ri.repairType=rp.id\n" +
            "JOIN repair_area ra \n" +
            "ON ri.repairArea=ra.id\n" +
            "JOIN account a\n" +
            "ON ri.acceptUser=a.id AND ri.repairUser=#{id}")
    IPage<myrepairInfo> personaluser(Page<myrepairInfo> page, @Param("id") Integer id);//根据学生的id查自己的维修情况



//    SELECT repairDate,repairNum,detailLocation,repairContent,area_name area, rp.project_name pname,ri.repairState FROM repair_info ri \n" +
//            "JOIN repair_area ra \n" +
//            "ON ri.repairArea=ra.id \n" +
//            "JOIN repair_project rp \n" +
//            "ON rp.id=ri.repairType \n" +
//            "JOIN account a\n" +
//            "ON ri.acceptUser=a.id\n" +
//            "AND repairNum=#{showrepairForm.repairNum}
    @Select("SELECT repairUserName username,userPhone,repairNum,area_name area,rp.project_name pname,ri.repairContent, ri.repairDate,ri.repairState from repair_info ri \n" +
            "JOIN repair_project rp \n" +
            "ON ri.repairType=rp.id\n" +
            "JOIN repair_area ra \n" +
            "ON ri.repairArea=ra.id AND repairNum=#{showrepairForm.repairNum} ")
    MyonerepairDto showmyrepair(@Param("showrepairForm")ShowrepairForm showrepairForm);//维修的详细信息

}
